package service

import (
	"context"
	"github.com/jinzhu/copier"
	"stageRpc/client"

	"github.com/cloudwego/hertz/pkg/app"
	stage "stage/hertz_gen/stage"
	stageRpcModel "stageRpc/kitex_gen/stage"
)

type GetZoomListService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewGetZoomListService(Context context.Context, RequestContext *app.RequestContext) *GetZoomListService {
	return &GetZoomListService{RequestContext: RequestContext, Context: Context}
}

func (h *GetZoomListService) Run(req *stage.Param) (resp *[]*stage.Zoom, err error) {
	var param = new(stageRpcModel.Param)
	if err = copier.Copy(param, req); err != nil {
		return nil, err
	}
	r, err := client.StageClient.GetZoomList(h.Context, param)
	if err != nil {
		return nil, err
	}
	var stageLIst = new([]*stage.Zoom)
	for _, v := range r {
		var tmp = new(stage.Zoom)
		if err = copier.Copy(tmp, v); err != nil {
			return nil, err
		}
		*stageLIst = append(*stageLIst, tmp)
	}
	return
}
